package com.shudes.game;

public class Card implements Comparable {

	protected Rank rank;
	protected Suit suit;	
	
	public Card(Rank r, Suit s) {
		rank=r;
		suit=s;
	}

	public Suit getSuit() { 
		return this.suit; 
	}
	
	public Rank getRank() { 
		return this.rank; 
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj==null) 
			return false; 
		
		return (obj instanceof Card) && this.hashCode()==obj.hashCode(); 		
	}

	@Override
	public int hashCode() {
		return (""+rank+"||"+suit).hashCode();
	}

	@Override
	public String toString() {
		return rank.getDescription() + suit.getDescription();
	}
	
	public int compareTo(Object o) { 
		Card c;
		
		if(o==null || !(o instanceof Card)) 
			return 1;
		
		c = (Card) o; 
		return (getRank()==c.getRank()) ? getSuit().compareTo(c.getSuit()) : getRank().compareTo(c.getRank()); 									
	}
	
	
	
	

}
